package com.fz.controller;

import com.fz.common.Result;
import com.fz.controller.request.BorrowPageRequest;
import com.fz.pojo.Borrow;
import com.fz.pojo.ReturnBooks;
import com.fz.service.ReturnService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("/return")
@CrossOrigin
public class ReturnController {
    @Autowired
    private ReturnService returnService;

    //分页
    @GetMapping("/pageReturn")
    public Result pageReturn(BorrowPageRequest pageRequest) {
        return Result.success(returnService.pageReturn(pageRequest));
    }


    // 添加
    @PostMapping("/addReturn")
    public Result addReturn(@RequestBody ReturnBooks returnBooks) {//这里要加@RequestBody 如果不加添加都是null
        returnService.addReturn(returnBooks);
        return Result.success();
    }

    //删除
    @DeleteMapping("/deleteReturn/{id}")
    public Result deleteReturn(@PathVariable Integer id) {
        returnService.deleteReturnById(id);
        return Result.success();
    }
}
